#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <iostream>
#include <QVector>
#include <QtScript/QScriptEngine>
#include <QRegularExpression>
#include <QDebug>
#include <math.h>
#include "3rdParty/exprtk.hpp"
#include "SymbolDefine.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void connectDigitKey(MainWindow *window);

    void connectOpKey(MainWindow *window);

    void connectFunctionKey(MainWindow *window);



private slots:
    void digitPressed();

    void spotPressed();

    void opPressed(); // calculate operation slot function

    void clearPressed(); // clear button slot function

    void delPressed(); // delete button slot function

    void equalPressed(); // equal button slot function

    void equalPressed_with3rd();

private:
    Ui::MainWindow *ui;
    QString input_text;  // input formula text
    QString output_text; // ouput answer text

    QVector<QString> insert_formula;

    QScriptEngine my_engine;

    int formula_dec_place = 1;
    bool can_insert_spot = true;

    void showText();

    QString qvec2qstr(QVector<QString> &string_vec);

    bool isOperatorSymbol(QString &str);

    typedef exprtk::symbol_table<double> symbol_table_t;
    typedef exprtk::expression<double>   expression_t;
    typedef exprtk::parser<double>       parser_t;
};
#endif // MAINWINDOW_H
